   <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility" %>
<%@ include file="/public/header.jsp"%>
<%
	String invoice_type = request.getParameter("invoice_type") == null ? "0" : request.getParameter("invoice_type");
%>
<html>
	<head>
		<title>项目开票选择</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$("#searchValue").keypress(function(e) { 
		    	// 回车键事件 
		     	if(e.which == 13) { 
		     		 doSearch();
		       	} 
			});
			$("#table").datagrid({
				title:"项目开票选择",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/xmFinance/listPageXMInvoice?invoice_type=<%=invoice_type%>&no_receive=1&status=3',
				rownumbers:true,
				fitColumns:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
				    {title:'主键',field:'id',hidden:true},
				]],
				columns:[[
					{title:'创建时间',field:'create_time',width:150,align:'center'},
					{title:'部门',field:'dept_name',width:100,align:'center'},
					{title:'项目编号',field:'xm_code',width:100,align:'center'},
					{title:'项目名称',field:'xm_name',width:100,align:'center'},
					{title:'票据抬头',field:'invoice_title',width:100,align:'center'},
					{title:'开票额',field:'account_receivable',width:100,align:'center'},
					{title:'已收额',field:'has_receivable',width:100,align:'center'},
					{title:'未收额',field:'not_receivable',width:100,align:'center',formatter:function(value,row,index){
						return row.account_receivable-row.has_receivable;
					}},
					{title:'选择操作',field:'choose',width:80,align:'center',formatter:function(value,rowData,rowIndex){
						
						return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-ok' title='选择此开票' onclick=\"javascript:choseXmInvoice('"+rowData.id+"','"+rowData.xm_id+"','"+rowData.xm_code+"','"+rowData.xm_name+"','"+rowData.account_receivable+"','"+rowData.has_receivable+"','"+rowData.invoice_title+"');\"/>";
					}}
				]],
				toolbar:"#tb",
				onDblClickRow:function(rowIndex, rowData){
					choseXmInvoice(rowData.id,rowData.xm_id,rowData.xm_code,rowData.xm_name,rowData.account_receivable,rowData.has_receivable,rowData.invoice_title);
				},
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		

		function  viewData(id){
		
			openDialogResize("<%=contextPath %>/springViews/xm/viewXmInvoice.jsp?id="+id+"&callback=rtCallBack&isShow=1",1000, 800);
	
		}
		
		function rtCallBack(){
			$('#table').datagrid('reload');
		}
		function choseXmInvoice(id,xm_id,code,name,account_receivable,has_receivable,invoice_title){
				window.opener.rtCallBackXmInvoiceSet(id,xm_id,code,name,account_receivable,has_receivable,invoice_title);
				window.close();
		}

		function doSearch()
		{
			var start_time=$('#start_time').datebox('getValue');  
			var end_time=$('#end_time').datebox('getValue');  
			var searchValue = $('#searchValue').val();
			$('#table').datagrid('load',{
				searchValue:searchValue,
				start_time:start_time,
				end_time:end_time
				
			});
		}
	</script>
	<body style="height: 97%">
		<div id="table" data-options="fit:true" ></div>
		<div id="tb" style="padding:3px;height:auto">
			<div align="right">
				开始时间：<input id="start_time" name="start_time" class="easyui-datebox" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" />
				项目名称/项目编号：<input id="searchValue" name="searchValue" style="width:150px" title="项目名称/项目编号"/>&nbsp;&nbsp;
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
			</div>
	</body>
</html>